package Entwickler;

import java.awt.Color;

public class Point {
	public double xPos = 0.0;
	public double yPos = 0.0;
	public double zPos = 0.0;
	public static int currentMaxIdentifier = 0;
	public int identifier;
	public Color color = new Color(0, 0, 0);
	
	public Polygon owner;
	private double xPosRotated = xPos;
	private double yPosRotated = yPos;
	private double zPosRotated = zPos;
	
	public Point (double xPos, double yPos, double zPos, Polygon owner){
		identifier = currentMaxIdentifier + 1;
		currentMaxIdentifier++;
		this.xPos = xPos;
		this.yPos = yPos;
		this.zPos = zPos;
		this.owner = owner;
	}
	
	public double getTransformedX(){
		double transformedXPos = (owner.xPos + xPos) * 500/(zPos + owner.zPos + 10);
		return transformedXPos;
	}
	
	public double getTransformedY(){
		double transformedYPos = (owner.yPos + yPos) * 500/(zPos + owner.zPos + 10);
		return transformedYPos;
	}
	
	
	public void rotate(double x, double y, double z){
		xPosRotated = xPos;
		yPosRotated = yPos;
		zPosRotated = zPos;
		
		double xPosRotatedTmp = xPos;
		double yPosRotatedTmp = yPos;
		
		yPosRotatedTmp = yPosRotated*Math.cos(x) - zPosRotated*Math.sin(x);
		zPosRotated = yPosRotated*Math.sin(x) + zPosRotated*Math.cos(x);
		yPosRotated = yPosRotatedTmp;
	
		xPosRotatedTmp = xPosRotated*Math.cos(y) + zPosRotated*Math.sin(y);
		zPosRotated = -xPosRotated*Math.sin(y) + zPosRotated*Math.cos(y);
		xPosRotated = xPosRotatedTmp;
	
		xPosRotatedTmp = xPosRotated*Math.cos(z) - yPosRotated*Math.sin(z);
		yPosRotated = xPosRotated*Math.sin(z) + yPosRotated*Math.cos(z);
		xPosRotated = xPosRotatedTmp;
		
		xPos = xPosRotated;
		yPos = yPosRotated;
		zPos = zPosRotated;
		
	}
	
	public void scale(double x, double y, double z){
		xPos *= x;
		yPos *= y;
		zPos *= z;
	}
}
